package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.OrderInfoQuery;
import com.example.orderflow.entity.po.OrderInfo;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.OrderInfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("orderInfoController")
@RequestMapping("/orderInfo")
public class OrderInfoController extends ABaseController {

	@Resource
	private OrderInfoService orderInfoService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(OrderInfoQuery query){
		return getSuccessResponseVO(orderInfoService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(OrderInfo bean) {
		orderInfoService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<OrderInfo> listBean) {
		orderInfoService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<OrderInfo> listBean) {
		orderInfoService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据OrderId查询对象
	 */
	@RequestMapping("/getOrderInfoByOrderId")
	public ResponseVO getOrderInfoByOrderId(String orderId) {
		return getSuccessResponseVO(orderInfoService.getOrderInfoByOrderId(orderId));
	}

	/**
	 * 根据OrderId修改对象
	 */
	@RequestMapping("/updateOrderInfoByOrderId")
	public ResponseVO updateOrderInfoByOrderId(OrderInfo bean,String orderId) {
		orderInfoService.updateOrderInfoByOrderId(bean,orderId);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据OrderId删除
	 */
	@RequestMapping("/deleteOrderInfoByOrderId")
	public ResponseVO deleteOrderInfoByOrderId(String orderId) {
		orderInfoService.deleteOrderInfoByOrderId(orderId);
		return getSuccessResponseVO(null);
	}
}